<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="../layui/css/layui.css"/>
	</head>
	<body style="padding: 10px;">

		<form class="layui-form" action="" lay-filter="formAddCustomer">
		  <div class="layui-form-item">
		    <label class="layui-form-label">客户名称</label>
		    <div class="layui-input-block">
		      <input type="text" name="cusName" autocomplete="off" placeholder="请输入客户名称" class="layui-input">
		    </div>
		  </div>
		  <div class="layui-form-item">
		    <label class="layui-form-label">客户编号</label>
		    <div class="layui-input-block">
		      <input type="text" name="cusNo" autocomplete="off" placeholder="请输入客户编号" class="layui-input">
		    </div>
		  </div>
			<div class="layui-form-item">
				<label class="layui-form-label">订单编号</label>
				<div class="layui-input-block">
					<input type="text" name="orNo" autocomplete="off" placeholder="请输入订单编号" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">商品名称</label>
				<div class="layui-input-block">
					<input type="text" name="orProductname" autocomplete="off" placeholder="请输入商品名称" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">商品数量</label>
				<div class="layui-input-block">
					<input type="text" name="orProductnumber" autocomplete="off" placeholder="请输入商品数量" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">商品价格</label>
				<div class="layui-input-block">
					<input type="text" name="orProductprice" autocomplete="off" placeholder="请输入商品价格" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">订单总金额</label>
				<div class="layui-input-block">
					<input type="text" id = "test2" name="orTotalprice" autocomplete="off" placeholder="请输入订单总金额" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">订单时间</label>
				<div class="layui-input-block">
					<input type="text" name="orDate" autocomplete="off" placeholder="请选择订单时间" id="order_time" class="layui-input">
				</div>
			</div>
		  <div class="layui-form-item">
		      <label class="layui-form-label">订单状态</label>
		      <div class="layui-input-block">
		        <select name="orState" lay-verify='required'>
		          <option value="isnull">请选择</option>
		          <option value="1">已处理</option>
		          <option value="0">未处理</option>
		        </select>
		      </div>
		  </div>
		   <div class="layui-form-item">
		      <div class="layui-input-block">
		        <button type="submit" class="layui-btn" lay-submit="" lay-filter="submitAddCustomer">立即提交</button>
		        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
		      </div>
		    </div>
		  </form>
		<script src="../layui/layui.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			layui.use(['form','jquery', 'laydate'], function(){
				var form = layui.form;
				var $ = layui.jquery;
				var laydate=layui.laydate;
				laydate.render({
					elem: '#order_time',
					type: 'datetime'
				});
					
				//submitAddCustomer提交按钮的lay-filter属性的值
				form.on('submit(submitAddCustomer)', function(d){
				    //d.field //表单的数据
					if(form.verify()){
						$.ajax({
							url:'http://localhost:8080/orders/addorders',
							type:'POST',//提交方式post,get...
							dataType:'JSON',//后台返回数据格式
							data:d.field, //要提交到后台的数据
							success:function(obj){
								//执行ajax提交成功后处理代码
								layer.msg(obj.msg)
								parent.table.reload('tblCustomer')
								var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
								parent.layer.close(index); //再执行关闭   
							}
						})
					}
				    return false;//阻止form提交刷新
				});
				 
			})
			
		</script>
		
			
	</body>
</html>
